// ==UserScript==
// @name         百度去广告插件
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        http*://*.baidu.com/*
// @icon         https://tb3.bdstatic.com/public/icon/favicon-v2.ico
// @grant        none
// ==/UserScript==

removeAD();
function removeAD(){
    setTimeout(function(){removeAD();},50);
    var no = document.getElementById("content_right");
    var nos = document.querySelectorAll('#content_right>table>tbody>tr>td>div');
    for(var n of nos){
        if(n.innerText!=undefined&&n.innerText.indexOf('400-800-8888')!=-1){
            console.log('移除推广链接 400-800-8888');
            n.remove();
        }
    }
    if(document.querySelectorAll("#content_left")[0] != null){
        var fathers = document.querySelectorAll("#content_left")[0].childNodes;
        var lastId = 0;
        for(var i = 0; i < fathers.length; i++){
            var currentNode = fathers[i];
            // 移除无意义的搜索结果
            if((currentNode.innerText+'').indexOf('csdn已为您找到')!=-1){
                console.log('移除 csdn已为您找到 相关内容'+currentNode.innerText);
                currentNode.remove();
                continue;
            }
            // 移除列表项
            if(fathers[i].tagName=="DIV"){
                var nodes = currentNode.querySelectorAll(".f13");
                for(var node of nodes){
                    if(node==null||node==undefined)continue;
                    if(node.innerText.indexOf('广告')!=-1){
                        console.log('移除 '+node.innerText);
                        currentNode.remove();
                    }
                }
            }
        }
    }
}